﻿var ocxObject;
function pageLoad() {

    

    //ocxObject = document.getElementById("OcxObject");
    //ocxObject.Destroy();
    //ocxObject.SetOcxMode(0);

    //if (ocxObject == null) {
    //    document.getElementById("downloadOCX").style.display = "block";
    //}
    //else {
    //    document.getElementById("downloadOCX").style.display = "none";
    //}

}

function startPreview(configXml) {
    //var previewXml = buildPreviewXml();
    var previewXml = configXml;
    var ret = ocxObject.StartTask_Preview_InWnd(previewXml, 0);
    ocxObject.setCapturParam("c:\\jnxc_pic", 0);//设置抓图存放路径

    if (ret == 0) {
    } else {
        //alert("startPreview fail >>> " + ret)
    }

}

//设置窗口分割数目
function setWndNum(num)
{
    var ret = ocxObject.SetWndNum(num);
    if (ret == 0) {
    } else {
        alert("SetWndNum fail >>> " + ret)
    }
}
//设置图片保存路径和格式
function setCapturParam(szPath, lPicType)
{
    //szPath： 图片保存路径 例如：c:\\pic,lPicType：0，jpeg格式；1,BMP格式	
    var ret = ocxObject.SetCapturParam(szPath, 0);
    if (ret == 0) {
        //alert("设置本地存储路径成功！路径为：" + szPath);
    } 
}
//
function startTaskptz() {
    var ret = ocxObject.StartTask_PTZ(23, 0)

    if (ret == 0) {
        //alert("sfd");
    } else {
        alert("StartTask_PTZ fail >>> " + ret)
    }
}
//
function PTZCtrlSet() {
    var ret = ocxObject.PTZCtrlSetPreset(165);

    if (ret == 0) {
        //alert("sfd");
    } else {
        alert("PTZCtrlSetPreset fail >>> " + ret)
    }
}

function PTZCtrlGOTO() {
    var ret = ocxObject.PTZCtrlGotoPreset(165);

    if (ret == 0) {
        //alert("sfd");
    } else {
        alert("PTZCtrlGotoPreset fail >>> " + ret)
    }
}

function buildPreviewXml() {
    //该XML可以自己写，也可以通过WebService获取预览所需的参数接口获取
    //return "<?xml version='1.0' encoding='UTF-8'?>"+
    //    "<Message><Camera>"+
    //    "<Id>1</Id>"+
    //    "<IndexCode>2015121711310018856</IndexCode>" +
    //    "<Name>IPdome</Name>" +
    //    "<ChanNo>0</ChanNo>" +
    //    "<Matrix Code='0' Id='0' /></Camera>" +
    //    "<Dev regtype='4' devtype='0'>" +
    //    "<Id>2</Id>" +
    //    "<IndexCode>201512171</IndexCode>" +
    //    "<Addr IP='223.99.163.178' Port='7302' />" +
    //    //"<Auth User='admin' Pwd='hik12345+'/>" +
    //    "</Dev>" +
    //    "<Vag IP='223.99.163.178' Port='7300' />" +
    //    "<Voice><Encode>1</Encode></Voice>" +
    //    "<User><Name>admin</Name><IP>223.99.163.179</IP></User>" +
    //    "<Media Protocol='0' Stream='0'>" + 
    //    "<Vtdu IP='223.99.163.178' Port='6010' /></Media>" +
    //    "<Privilege Priority='50' Code='3' />" +
    //    "<Option><Talk>1</Talk><PreviewType>1</PreviewType></Option></Message>";

    var xmlstr = "<?xml version='1.0' encoding='UTF-8'?>" +
  "<Message>" +
  "<Camera>" +
  "<Id>1</Id>" +
  "<IndexCode>2015121711310018856</IndexCode>" +
  "<Name>IP DOME</Name>" +
  "<ChanNo>0</ChanNo>" +
  "<Matrix Code=0 Id=0 />" +
  "</Camera>" +
  "<Dev regtype=0 devtype=1>" +
  "<Id>1</Id>" +
  "<IndexCode>201512171</IndexCode>" +
  "<Addr IP='223.99.163.178' Port='7302' />" +
  "<Auth User='admin' Pwd='hik12345+' />" +
  "</Dev>" +
  "<Vag IP='223.99.163.178' Port='7302' />" +
  //"<Voice><Encode>1</Encode></Voice>" +
  //"<User>" +
  //"<Name>admin</Name>" +
  //"<IP>223.99.163.178</IP>" +
  //"</User>" +
  //"<Media Protocol='0' Stream='0'><Vtdu IP='223.99.163.178' Port='554' /></Media>" +
  "<Privilege Priority=1 Code=15 />" +
  //"<Option><Talk>1</Talk><PreviewType>0</PreviewType></Option>" +
  "</Message>";

    return xmlstr;
}
